home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
INFO
/
DOSTIPS5.ZIP
/
DOSKYBD
< prev
next >
Wrap
Text File
|
1986-06-28
|
5KB
|
111 lines
IBM Keyboard Customizer
(COMPUTE! Magazine July 1986 by David Engebretsen)
It is surprisingly easy to reassign any key or keys to a location
that suits your own personal needs. The first step is to create a
CONFIG.SYS file that installs an extended screen and keyboard control
device driver when you boot the system. At the DOS prompt, simply
type:
A>COPY CON:CONFIG.SYS
DEVICE=ANSI.SYS
Press the F6 key followed by Return. The configuration file runs
automatically when you boot the computer, and it is ready to accept
new key assignments.
The next step is to do the actual key switching. Since this can
involve some odd character sequences, it's easiest to do this from
within a BASIC program that stores the needed data in a text file on
disk. Use this program to create a file that changes the uppercase Q
to an uppercase D:
10 A$=CHR$(27)+"["+CHR$(34)+"Q"+CHR$(34)+";"+CHR$(34)+"D"+CHR$(34)+"p"
20 OPEN "KEY.TXT" FOR OUTPUT AS #1
30 PRINT #1,A$
40 CLOSE #1
Save this program as REASSIGN.BAS and run it. REASSIGN.BAS creates a
text file that contains the following character sequence:
ESC["Q";"D"p
CHR$(27) is the ASCII code for the ESC character; this is the control
code which changes the uppercase Q into an uppercase D. To implement
this change, insert the disk containing your new CONFIG.SYS file, then
reboot. This enables the ANSI device driver which in turn allows the
keyboard to be redefined.
Type TYPE KEY.TXT at the DOS prompt and press Return. This enters
the special control characters into the computer's memory. Now when
you type an uppercase Q, the system substitutes an uppercase D.
The same technique can be used to create a keyboard macro -- a
key that produces a multicharacter word or phrase with just one
keystroke. To illustrate, uppercase Q can be redefined so that it
prints the phrase "The Phrase." Replace line 10 in the BASIC program
above with:
10 A$=CHR$(27)+"["+CHR$(34)+"Q"+CHR$(34)+";"+CHR$(34)+"The Phrase"+CHR$(34)+"p"
Run the program again. This creates a text file with these characters:
ESC["Q";"The Phrase"p
Return to DOS and type TYPE KEY.TXT again. Now when you press Q the
computer prints The Phrase on the screen.
When creating the KEY.tXT file, it is also acceptable to use an
ASCII code for the character. For example, if you want to change
uppercase Q back to uppercase D, change line 10 in the program to:
19 A$=CHR$(27)+"[81;68p"
Run the program, return to DOS, type TYPE KEY.TXT, and uppercase Q
will produce uppercase D again.
By supplying an extended ASCII code, you can redefine the ten
function keys alone or in conjunction with the Ctrl, Shift, or Alt
keys. That comes to four sets of ten, or 40 keys. Rerun the program
with line 10 changed to:
10 A$=CHR$(27)+"[0;84;"+CHR$(34)+"DIR"+CHR$(34)+";13p"
The following text file is created:
ESC [0;84;"DIR";p
The 0 before the 84 tells the computer to look for an extended keycode
-- a code that signals a special key combination. The extended keycode
84 represents Shift-F1, and this key combination is redefined so that
it prints DIR followed by a carriage return. Run the program, return
to DOS, and type TYPE KEY.TXT. Now when you hold down Shift and press
F1, the disk directory is displayed.
Note the number 13 just before the p in this character sequence.
This is the ASCII code for Return. Adding this character to the end
of a character sequence has the same effect as pressing Return manually
on the keyboard. The computer types the letters D-I-R, then issues a
Return to carry out the command.
Using a similar method, you can also change the screen color or
shift to a different screen resolution. To change colors, replace the
lowercase p in line 10 with a lowercase m, and supply an appropriate
color number. For instance, change line 10 to:
10 A$=CHR$(27)+"[37;44m"
Now the program creates this text file:
ESC [37;44m
When this file is TYPEd from DOS, the screen turns blue.
The same procedure works for changing the screen mode. Change
line 10 to:
10 A$=CHR$(27)+"[=1h"
When you TYPE the resulting file from DOS, the screen goes into 40 x 25
color text mode. To obtain 320 x 200 color graphics mode, simply
change the number 1 in line 10 to a 4.
The customizations you create using these techniques stay in
effect as long as you are working in DOS or a DOS-related program.
These changes disappear, however, if you reboot the computer, go to
BASIC, or run an application that imposes its own definitions on the
system.
The ASCII codes for the various characters and colors are listed
in the BASIC and DOS manuals.